package com.dongdong.zhuangji.controller.utils;

import lombok.Data;

/**
 * @author dongdong 抖音号：W13883155245
 * @version 1.0
 * @date 2025/5/4
 * @description 统一数据格式提供给前端
 */
@Data
public class R {
    private Boolean flag;
    private String msg;
    private Object data;

    public R() {
    }
    public R(Boolean flag) {
        this.flag = flag;
        if (flag) {
            this.msg = "操作成功";
        }else {
            this.msg = "操作失败";
        }

    }
    public R( Object data) {

        this.data = data;
        if (data!=null) {
            this.flag = true;
            this.msg = "操作成功";
        }else {
            this.flag = false;
            this.msg = "操作失败";
        }

    }

    public R(Boolean flag, String msg) {
        this.flag = flag;
        this.msg = msg;
    }

    public R(Boolean flag, Object data) {
        this.flag = flag;
        this.data = data;
    }

    public R(Boolean flag, String msg, Object data) {
        this.flag = flag;
        this.msg = msg;
        this.data = data;
    }
}
